﻿#pragma once

#include <algorithm>
#include <tuple>
#include <cmath>
#include <graphics.h>

// 存放一些可以复用的函数

// 视图状态结构体
struct ViewState {
    float scale = 1.0f;
    float offsetX = 0.0f;
    float offsetY = 0.0f;
    float targetScale = 1.0f;
    float targetOffsetX = 0.0f;
    float targetOffsetY = 0.0f;
    float velocityX = 0.0f;
    float velocityY = 0.0f;
};

// 窗口参数结构体
struct WindowParams {
    int width;
    int height;
    float base_width;
    float base_height;
};

extern mouse_msg msg;
extern bool leftButtonDown;
extern BYTE alpha;//透明度
extern double LV;//亮度（0.0-1.0
extern PIMAGE bkpfd;

WindowParams initializeWindow();
void reverseTransmission(float flap, float gear1);
void handleMouseInput(ViewState& state, const WindowParams& window);
void handleKeyboardInput(ViewState& state, float deltaTime);
void updateMovement(ViewState& state, float deltaTime);
std::tuple<int, int, int> calculateViewportParams(
    const ViewState& state,
    float base_x,
    float base_y,
    float base_size,
    const WindowParams& window
);
void drawbkPFD(int x0, int y0, double pfd_h);